var express = require('express');
let tools = require('../common/tools');
var router = express.Router();

/* GET home page. */

router.get('/', function (req, res) {
  // if (req.session.user) {
  //   res.render('index', {user:req.session.user});
  // } else {
    res.render('index', {user:false,title:'首页'});
  //}
});

router.get('/choose-district', function(req, res) {
  res.render('choose-district', {title: '选择小区'});
});

// 管理员 与我相关
router.get('/my', function(req, res) {
  res.render('my/my', {title: '与我相关'});
});

router.get('/myPosts', function(req, res) {
  res.render('my/myPosts', {title: '我发布的帖子'});
});

router.get('/peopleDetail', function(req, res) {
  res.render('my/peopleDetail', {title: '人员详情'});
});

router.get('/applyRecords', function(req, res) {
  res.render('my/peopleDetail', {title: '申请记录'});
});

router.get('/writeMsg', function(req, res) {
  res.render('my/writeMsg', {title: '信息填写'});
});

router.get('/vote/voteDetail2', function(req, res) {
  res.render('my/voteDetail', {title: '投票详情'});
});

router.get('/vote/voteDetail1',function(req,res){
  res.render('vote/vote',{title:"投票详情"})
})


router.get('/joinGroup', function(req, res) {
  res.render('my/joinGroup', {title: '新人入群'});
});

// 举报管理
router.get('/reportList', function(req, res) {
  res.render('report/reportList', {title: '举报'});
});

router.get('/reportDetail', function(req, res) {
  res.render('report/reportDetail', {title: '处理详情'});
});

// 系统消息
router.get('/sysMessage', function(req, res) {
  res.render('sysMessage', {title: '系统消息'});
});

// 我的动态
router.get('/myMessage', function(req, res) {
  res.render('my/myMessage', {title: '消息'});
});


router.get('/advice', function(req, res) {
  res.render('advice/advice', {title: '投诉与建议'});
});

router.get('/detail', function(req, res) {
  res.render('detail/detail', {title: '帖子详情'});
});

//报名帖子详情
router.get('/detail-sign', function(req, res) {
  res.render('detail/detail-sign', {title: '报名活动详情'});
});
//报名信息填写
router.get('/sign-form', function(req, res) {
  res.render('detail/sign-form', {title: '报名信息填写'});
});


router.get('/comment', function(req, res) {
  res.render('detail/comment', {title: '发评论'});
});

var admin = express.Router()

admin.get('/post-sign', function(req, res) {
  res.render('admin/post-sign', {title: '发布报名'});
});

admin.get('/post-vote', function(req, res) {
  res.render('admin/post-vote', {title: '发布投票'});
});

admin.get('/post-notice', function(req, res) {
  res.render('admin/post-notice', {title: '发布公告'});
});
admin.get('/post-notice2', function(req, res) {
  res.render('admin/post-notice2', {title: '发布公告'});
});


admin.get('/post-post', function(req, res) {
  res.render('admin/post-post', {title: '发布帖子'});
});

router.use('/admin',admin)

var noadmin = express.Router();

noadmin.get('/posts',(req,res)=>{
  res.render('noadmin/posts',{title:'非管理员发布的帖子'})
})

router.use('/noadmin',noadmin);

router.get('/down',function(req,res) {
  res.download('./public/images/生活服务.png')
})

var multer  = require('multer')
var upload = multer({ dest: 'uploads/' })

router.post('/suck',upload.single('lname'),function(req, res, next){
  console.log(req.file);
})
router.get('/fuck',function(req,res){
  res.render('demo')
})

router.get('/position',function(req,res){
  res.render('position')
})
module.exports = router;
